/**********************************
 * @Author: Qi Hang
 * @LastEditor: Qi Hang
 * @LastEditTime: 20:23:59, 星期日 18, 五月 2025
 * @Email: wqwzxwzx@gmail.com
 * Copyright © 2023 Qi Hang | https://hanghang.xyz
 **********************************/

const baseTitle = import.meta.env.VITE_TITLE;

export function createPageTitleGuard(router) {
  router.afterEach((to) => {
    const pageTitle = to.meta?.title;
    if (pageTitle) {
      document.title = `${pageTitle} | ${baseTitle}`;
    } else {
      document.title = baseTitle;
    }
  });
}
